package com.zsr.example.util;

import com.zsr.example.service.BusinessService;
import com.zsr.example.service.EduArticleService;
import com.zsr.example.service.EduCourseService;
import com.zsr.example.service.EduPathService;
import com.zsr.example.service.impl.EduArticleServiceImpl;
import com.zsr.example.service.impl.EduCourseServiceImpl;
import com.zsr.example.service.impl.EduPathServiceImpl;
import com.zsr.example.util.constants.BusinessEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;

/**
 * @author zhousiren
 * @description
 * @date 2022/4/16 12:53
 */
@Component
public class BusinessUtil {

    private static BusinessUtil  staticInstance = new BusinessUtil();

    @Autowired
    private EduArticleService articleService;
    @Autowired
    private EduCourseService courseService;
    @Autowired
    private EduPathService pathService;

    private static HashMap<Integer,BusinessService> map=new HashMap<>();

    @PostConstruct
    public void init(){
        map.put(BusinessEnum.COURSE.getType(),courseService);
        map.put(BusinessEnum.ARTICLE.getType(),articleService);
        map.put(BusinessEnum.PATH.getType(),pathService);
    }

    public static BusinessService  getBusService(Integer targetId){
        return map.get(targetId);
    }


}
